//package com.avic.rong.utils;
//
//import android.content.Context;
//import android.widget.ImageView;
//
////import com.bumptech.glide.Glide;
//
///**
// * Creater: Created by wangyz on 2017/1/21.
// * Email: 936804097@qq.com
// */
//
//public class GlideUtil {
//
//    /**
//     * 常量
//     */
//    public static class Contants {
//        public static final int BLUR_VALUE = 20; //模糊
//        public static final int CORNER_RADIUS = 20; //圆角
//        public static final float THUMB_SIZE = 0.5f; //0-1之间  10%原图的大小
//        public static final int CORNER_RADIUS_3DP = 8;
//    }
//
//
//    public static void loadImage(Context context, ImageView imageView,
//                          String imgUrl) {
//
////        Glide.with(context).load(imgUrl).into(imageView);
//    }
//
//
//
//
//
//    /**
//     * 常规加载图片
//     *
//     * @param context
//     * @param imageView 图片容器
//     * @param imgUrl    图片地址
//     * @param isFade    是否需要动画
//     */
////    public void loadImage(Context context, ImageView imageView,
////                          String imgUrl, boolean isFade) {
////        if (isFade) {
////            Glide.with(context)
////                    .load(imgUrl)
////                    .error(R.mipmap.error)
////                    .crossFade()
////                    .priority(Priority.NORMAL) //下载的优先级
////                    //all:缓存源资源和转换后的资源 none:不作任何磁盘缓存
////                    //source:缓存源资源   result：缓存转换后的资源
////                    .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                    .into(imageView);
////        } else {
////            Glide.with(context)
////                    .load(imgUrl)
////                    .error(R.mipmap.error)
////                    .into(imageView);
////        }
////    }
////
////
////    public void loadImage(Context context, ImageView imageView,
////                          String imgUrl, int withSize, int heightSize, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(defaultImage)
////                .crossFade()
////                .override(withSize, heightSize)
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .into(imageView);
////    }
////
////    public void loadImageWang(final Context context, final ImageView imageView,
////                              String imgUrl, int withSize, int heightSize, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .placeholder(defaultImage)
////                .error(defaultImage)
////                .crossFade()
////                .skipMemoryCache(false)
////                .override(withSize, heightSize)
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .into(imageView);
////    }
////
////
////    /**
////     * 加载缩略图
////     *
////     * @param context
////     * @param imageView 图片容器
////     * @param imgUrl    图片地址
////     */
////    public void loadThumbnailImage(Context context, ImageView imageView, String imgUrl) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(R.mipmap.error)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .thumbnail(Contants.THUMB_SIZE)
////                .into(imageView);
////    }
////
////    /**
////     * 加载图片并设置为指定大小
////     *
////     * @param context
////     * @param imageView
////     * @param imgUrl
////     * @param withSize
////     * @param heightSize
////     */
////    public void loadOverrideImage(Context context, ImageView imageView,
////                                  String imgUrl, int withSize, int heightSize) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(R.mipmap.icon_ency_default)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .override(withSize, heightSize)
////                .into(imageView);
////    }
////
////    /**
////     * 加载图片并对其进行模糊处理
////     *
////     * @param context
////     * @param imageView
////     * @param imgUrl
////     */
////    public void loadBlurImage(Context context, ImageView imageView, String imgUrl) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(R.mipmap.error)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .bitmapTransform(new BlurTransformation(context, Contants.BLUR_VALUE))
////                .into(imageView);
////    }
////
////    /**
////     * 加载圆图
////     *
////     * @param context
////     * @param imageView
////     * @param imgUrl
////     */
////    public void loadCircleImage(Context context, ImageView imageView, String imgUrl) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(R.mipmap.error)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .bitmapTransform(new CropCircleTransformation(context))
////                .into(imageView);
////    }
////
////    /**
////     * 加载模糊的圆角的图片
////     *
////     * @param context
////     * @param imageView
////     * @param imgUrl
////     */
////    public void loadBlurCircleImage(Context context, ImageView imageView, String imgUrl) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(R.mipmap.error)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .bitmapTransform(
////                        new BlurTransformation(context, Contants.BLUR_VALUE),
////                        new CropCircleTransformation(context))
////                .into(imageView);
////    }
////
////    /**
////     * 加载圆角图片
////     *
////     * @param context
////     * @param imageView
////     * @param imgUrl
////     */
////    public void loadCornerImage(Context context, ImageView imageView, String imgUrl) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(R.mipmap.error)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .bitmapTransform(
////                        new RoundedCornersTransformation(
////                                context, Contants.CORNER_RADIUS, Contants.CORNER_RADIUS))
////                .into(imageView);
////    }
////
////    public void loadCornerUpImage(final Context context, final ImageView imageView, String imgUrl, final int withSize, final int heightSize, final int radius, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(defaultImage)
////                .crossFade()
////                .override(withSize, heightSize)
////                .priority(Priority.IMMEDIATE) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.RESULT) //缓存策略
////                .centerCrop()
////                .bitmapTransform(new CenterCrop(context),
////                        new RoundedCornersTransformation(
////                                context, radius, 0, RoundedCornersTransformation.CornerType.TOP))
////                .into(imageView);
////
////    }
////
////    public void loadCornerBottom(final Context context, final ImageView imageView, String imgUrl, final int withSize, final int heightSize, final int radius, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(defaultImage)
////                .crossFade()
////                .override(withSize, heightSize)
////                .priority(Priority.IMMEDIATE) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.RESULT) //缓存策略
////                .bitmapTransform(new FitCenter(context),
////                        new RoundedCornersTransformation(
////                                context, radius, 0, RoundedCornersTransformation.CornerType.BOTTOM))
////                .into(imageView);
////    }
////
////
////    public void loadCornerUpImageForBrand(final Context context, final ImageView imageView, String imgUrl, final int withSize, final int heightSize, final int radius, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .placeholder(defaultImage)
////                .error(defaultImage)
////                .crossFade()
////                .override(withSize, heightSize)
////                .priority(Priority.IMMEDIATE) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.RESULT) //缓存策略
////                .bitmapTransform(new FitCenter(context),
////                        new RoundedCornersTransformation(
////                                context, radius, 0, RoundedCornersTransformation.CornerType.TOP))
////                .into(imageView);
////    }
////
////    public void loadCornerImageFitCenter(final Context context, final ImageView imageView, String imgUrl, final int withSize, final int heightSize, final int radius, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .placeholder(defaultImage)
////                .error(defaultImage)
////                .crossFade()
////                .override(withSize, heightSize)
////                .priority(Priority.IMMEDIATE) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.RESULT) //缓存策略
////                .bitmapTransform(new FitCenter(context),
////                        new RoundedCornersTransformation(
////                                context, radius, 0, RoundedCornersTransformation.CornerType.ALL))
////                .into(imageView);
////    }
////
////
////    public void loadCornerImage(Context context, ImageView imageView, String imgUrl, int mipmapId) {
////        Glide.with(context)
////                .load(imgUrl)
////                .placeholder(mipmapId)
////                .error(mipmapId)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .bitmapTransform(
////                        new RoundedCornersTransformation(
////                                context, Contants.CORNER_RADIUS, Contants.CORNER_RADIUS))
////                .into(imageView);
////
////    }
////
////
////    public void loadCornerImage(Context context, ImageView imageView, String imgUrl, int withSize, int heightSize, int errorImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .placeholder(errorImage)
////                .error(errorImage)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .override(withSize, heightSize)
////                .bitmapTransform(
////                        new RoundedCornersTransformation(
////                                context, Contants.CORNER_RADIUS_3DP, 0))
////                .into(imageView);
////    }
////
////    public void loadCornerImageByRadius(Context context, ImageView imageView, String imgUrl, int withSize, int heightSize, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .placeholder(defaultImage)
////                .error(defaultImage)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .override(withSize, heightSize)
////                .bitmapTransform(
////                        new RoundedCornersTransformation(
////                                context, Contants.CORNER_RADIUS_3DP, 0))
////                .into(imageView);
////    }
////
////    public void loadCornerImageByRadiusMask(final Context context, final ImageView imageView, String imgUrl, int withSize, int heightSize, final int radius, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .override(withSize, heightSize)
////                .placeholder(defaultImage)
////                .error(defaultImage)
////                .crossFade()
////                .bitmapTransform(new CenterCrop(context), new RoundedCornersTransformation(context, radius, 0), new MaskTransformation(context, R.drawable.bg_ce_ping_mask))
////                .into(imageView);
////    }
////
////
////    public void loadCornerImageByRadius(final Context context, final ImageView imageView, String imgUrl, int withSize, int heightSize, final int radius, int defaultImage) {
////        Glide.with(context)
////                .load(imgUrl)
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .override(withSize, heightSize)
////                .placeholder(defaultImage)
////                .error(defaultImage)
////                .crossFade()
////                .bitmapTransform(new CenterCrop(context), new RoundedCornersTransformation(context, radius, 0))
////                .into(imageView);
////
////    }
////
////    /**
////     * 加载模糊的圆角图片
////     *
////     * @param context
////     * @param imageView
////     * @param imgUrl
////     */
////    public void loadBlurCornerImage(Context context, ImageView imageView, String imgUrl) {
////        Glide.with(context)
////                .load(imgUrl)
////                .error(R.mipmap.error)
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .bitmapTransform(
////                        new BlurTransformation(context, Contants.BLUR_VALUE),
////                        new RoundedCornersTransformation(
////                                context, Contants.CORNER_RADIUS, Contants.CORNER_RADIUS))
////                .into(imageView);
////    }
////
////    /**
////     * 同步加载图片
////     *
////     * @param context
////     * @param imgUrl
////     * @param target
////     */
////    public void loadBitmapSync(Context context, String imgUrl, SimpleTarget<Bitmap> target) {
////        Glide.with(context)
////                .load(imgUrl)
////                .asBitmap()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .into(target);
////    }
////
////    /**
////     * 加载gif
////     *
////     * @param context
////     * @param imageView
////     * @param imgUrl
////     */
////    public void loadGifImage(Context context, ImageView imageView, String imgUrl) {
////        Glide.with(context)
////                .load(imgUrl)
////                .asGif()
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .error(R.mipmap.error)
////                .into(imageView);
////    }
////
////    /**
////     * 加载gif的缩略图
////     *
////     * @param context
////     * @param imageView
////     * @param imgUrl
////     */
////    public void loadGifThumbnailImage(Context context, ImageView imageView, String imgUrl) {
////        Glide.with(context)
////                .load(imgUrl)
////                .asGif()
////                .crossFade()
////                .priority(Priority.NORMAL) //下载的优先级
////                .diskCacheStrategy(DiskCacheStrategy.ALL) //缓存策略
////                .error(R.mipmap.error)
////                .thumbnail(Contants.THUMB_SIZE)
////                .into(imageView);
////    }
//
//    /**
//     * 恢复请求，一般在停止滚动的时候
//     *
//     * @param context
//     */
//    public void resumeRequests(Context context) {
////        Glide.with(context).resumeRequests();
//    }
//
//    /**
//     * 暂停请求 正在滚动的时候
//     *
//     * @param context
//     */
//    public void pauseRequests(Context context) {
////        Glide.with(context).pauseRequests();
//    }
//
//    /**
//     * 清除磁盘缓存
//     *
//     * @param context
//     */
//    public void clearDiskCache(final Context context) {
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
////                Glide.get(context).clearDiskCache();//清理磁盘缓存 需要在子线程中执行
//            }
//        }).start();
//    }
//
//    /**
//     * 清除内存缓存
//     *
//     * @param context
//     */
//    public void clearMemory(Context context) {
////        Glide.get(context).clearMemory();//清理内存缓存  可以在UI主线程中进行
//    }
//
//}
